CREATE TABLE [dbo].[tb_Jornadas]
(
[idJornada] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updatetb_Jornadas] ON [dbo].[tb_Jornadas]
 FOR UPDATE AS 
 IF (update(idJornada)) begin 
	 SELECT * FROM inserted 
	 IF @@ROWCOUNT = 1 begin 
		 UPDATE tb_FuncionesDeGrilla
		 SET Jornada = (SELECT idJornada FROM inserted)
		 WHERE tb_FuncionesDeGrilla.Jornada = (SELECT idJornada FROM deleted)
	end  ELSE begin 
		 ROLLBACK TRANSACTION 
 end 
 end
GO
ALTER TABLE [dbo].[tb_Jornadas] ADD CONSTRAINT [PK_tb_Jornadas] PRIMARY KEY NONCLUSTERED  ([idJornada]) ON [PRIMARY]
GO
